﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Chowpoo.Common;
using Chowpoo.Util;
using CourseSystem.Common;
using CourseSystem.Common.Helpers;
using CourseSystem.Core.BLL;
using CourseSystem.Core.Entities;
using Webdiyer.WebControls.Mvc;

namespace CourseSystem.Web.Controllers
{
    public class GuideController : BaseController
    {
        //
        // GET: /Guide/

        public ActionResult News()
        {
            return View();
        }

        public ActionResult NewsListUc(int? pid, string search, string startDate, string endDate)
        {
            CommonRequest.ClearCache();
            var list = CourseNoticeBLL.GetList(search, startDate.CheckNoDatetime(), endDate.CheckNoDatetime()).OrderByDescending(o => o.Id);
            var model = list.ToPagedList(pid ?? 1, CommonHelper.PageSize);
            return PartialView(model);
        }

        public ActionResult Index(int? id, int? min)
        {
            var getId = id ?? 1;
            CourseGuideSubMenuInfo info = null;
            if (!min.HasValue)
            {
                info = CourseGuideSubMenuBLL.GetByMenuId(getId);
                if (info == null)
                    info = new CourseGuideSubMenuInfo { CommonContentInfo = new CommonContentInfo { DetailContent = "" }, MenuId = getId };
            }
            else
                info = CourseGuideSubMenuBLL.Get(getId, min.Value);
            if (info == null)
                return View("NotFound");
            return View(info);
        }

    }
}
